<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>threeJsDemo</title>
    <script src="https://cdn.bootcss.com/three.js/r83/three.min.js"></script>
</head>
<body>

<script>
    var scene = new THREE.Scene();  // 场景
    var camera = new THREE.PerspectiveCamera(75, window.innerWidth/window.innerHeight, 0.1, 1000);// 透视相机
    var renderer = new THREE.WebGLRenderer();   // 渲染器
    renderer.setSize(window.innerWidth, window.innerHeight);    // 设置渲染器的大小为窗口的内宽度，也就是内容区的宽度
    document.body.appendChild(renderer.domElement);

    var geometry = new THREE.CubeGeometry(1,1,1);
    var material = new THREE.MeshBasicMaterial({color: 0x00AAFF});
    var cube = new THREE.Mesh(geometry, material);
    scene.add(cube);

    camera.position.z = 8;
    function render() {
        requestAnimationFrame(render);
        cube.rotation.x += 0.01;
        cube.rotation.y += 0.01;
        cube.rotation.z += 0.01;
        renderer.render(scene, camera);
    }

    render();

</script>
</body>
</html>